//
//  Service+Favorite.m
//  huimei
//
//  Created by fengyn on 16/1/29.
//  Copyright © 2016年 lexingsoft. All rights reserved.
//

#import "Service+Favorite.h"

@implementation ServiceManager(Favorite)
///公网用户收藏
+ (void)favoriteContentWithId:(NSString *)theId type:(NSString *)type success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/userfavorite";
    NSDictionary *parameterDict=@{@"contentSequenceNbr":theId,
                                  @"businessType":type};
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///公网用户取消收藏
+ (void)cancelFavoriteContentWithId:(NSString *)theId type:(NSString *)type success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/userfavorite";
    NSDictionary *parameterDict=@{@"contentSequenceNbr":theId,
                                  @"businessType":type};
    [NetworkClient deleteRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///公网用户查询收藏
+ (void)getFavoriteWithType:(NSString *)type pageIndex:(NSUInteger)pageIndex success:(void(^)(NSDictionary * data)) success failure:(void(^)()) failure
{
    NSString * path = @"/userfavorite";
    const int countPer=20;
    NSDictionary *parameterDict=@{@"start":@(pageIndex*countPer),
                                  @"length":@(countPer),
                                  @"businessType":type};
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}
@end
